<form action="{:sysuri()}?code={$get.code|default=''}" data-table-id="GoodsTable" class="layui-form layui-card" data-auto="true" method="post">
    <div class="layui-card-body padding-left-40">

        <div class="layui-form-item relative">
            <span class="help-label"><b>商品编号</b>Goods Code</span>
            <div class="layui-input layui-bg-gray">{$vo.code|default=''}</div>
        </div>

        <div class="layui-form-item relative">
            <span class="help-label"><b>商品名称</b>Goods Name</span>
            <div class="layui-input layui-bg-gray">{$vo.name|default=''}</div>
        </div>

        <div class="layui-form-item relative">
            <span class="help-label"><b>库存数据</b>Goods Stock Data</span>
            <table class="layui-table border-0 margin-0" lay-skin="nob">
                <colgroup>
                    <col style="width:auto">
                    <col style="width:80px">
                    <col style="width:80px">
                    <col style="width:80px">
                    <col style="width:80px">
                    <col style="width:80px">
                    <col style="width:99px">
                    <col style="width:18px">
                </colgroup>
                <thead>
                <tr class="layui-bg-cyan notselect">
                    <th class="text-left nowrap">商品规格</th>
                    <th class="text-center nowrap">市场价格</th>
                    <th class="text-center nowrap">销售价格</th>
                    <th class="text-center nowrap">库存统计</th>
                    <th class="text-center nowrap">总销统计</th>
                    <th class="text-center nowrap">库存剩余</th>
                    <th class="text-center nowrap pointer" data-batchset data-tips-text="批量设置库存">
                        <i class="layui-icon font-s10" style="color:#FFF">&#xe63c;</i> 入库数量
                    </th>
                    <th class="padding-0"></th>
                </tr>
                </thead>
            </table>
            <div style="max-height:500px;overflow-y:scroll">
                <table class="layui-table margin-0" lay-skin="line">
                    <colgroup>
                        <col style="width:auto">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:80px">
                        <col style="width:99px">
                    </colgroup>
                    <tbody>
                    {foreach $vo.items as $goods}
                    <tr>
                        <td class="layui-bg-gray layui-elip">{$goods.gspec|show_gspec}</td>
                        <td class="layui-bg-gray text-center">￥{$goods.price_market+0}</td>
                        <td class="layui-bg-gray text-center">￥{$goods.price_selling+0}</td>
                        <td class="layui-bg-gray text-center">{$goods.stock_total|default=0}</td>
                        <td class="layui-bg-gray text-center">{$goods.stock_sales|default=0}</td>
                        <td class="layui-bg-gray text-center">{$goods.stock_total-$goods.stock_sales}</td>
                        <td class="padding-0 nowrap">
                            <input name="gcode[]" type="hidden" value="{$goods.gcode|default=''}">
                            <input name="gspec[]" type="hidden" value="{$goods.gspec|default=''}">
                            <input name="ghash[]" type="hidden" value="{$goods.ghash|default=''}">
                            <label class="relative flex flex-align-center">
                                <input class="layui-input text-center border-0 flex-1" type="number" min="0" data-blur-number="0" maxlength="20" name="gstock[]" value="0">
                                <span class="layui-bg-gray padding-left-5 padding-right-5">件</span>
                            </label>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>确定入库</button>
        <button class="layui-btn layui-btn-danger" data-close data-confirm="确定要取消入库吗？" type='button'>取消入库</button>
    </div>
</form>

<script>
    $('[data-batchset]').on('click', function () {
        layer.prompt({
            title: '请输入库存数量【 取值范围：1 - 999999 】',
            formType: 0, value: 1, success: function ($ele) {
                $ele.find('.layui-layer-input').attr({'data-value-min': 1, 'data-value-max': 999999, 'data-blur-number': 0});
            }
        }, function (value, index) {
            layer.close(index) || $('[name^="gstock"]').val(parseInt(value) || 0);
        });
    });
</script>
